package viewPackage;

import java.awt.Point;

public class Line {

	private double slope;
	private double intercept;
	
	public Line(Point p1, Point p2) {
		
		double p1y = (double) p1.y;
		double p1x = (double) p1.x;
		double p2y = (double) p2.y;
		double p2x = (double) p2.x;
		
		this.slope = (p1y - p2y) / (p1x - p2x);
		this.intercept = p1y - (this.slope * p1x);		
	}
	
	public Line(double slope, double intercept) {
		this.slope = slope;
		this.intercept = intercept;
	}
	
	public double getSlope() {
		return this.slope;
	}
	
	public double getIntercept() {
		return this.intercept;
	}
	
	public Point lineIntercept(Line that) {
		double x = (that.getIntercept() - this.getIntercept()) / (this.getSlope() - that.getSlope());
		double y = (x * this.getSlope()) + this.getIntercept();
		
		return new Point((int)x,(int)y);
	}
}

